#include "../Header/stringsort.h"

void PrintStringliste(char *list[])
{
    int a;
    for(a = 0; *list[a] != '\0'; ++a)
    {
        printf("%s, %d\n", list[a], (int)sizeof(list[a]));
    }
}

void SortiereStrings(char *list[])
{
    char getauscht = '1';
    int i, tmp;
    
    while(getauscht == '1')
    {
        getauscht = '0';
        
        for(i = 0; *list[i + 1] != '\0'; ++i)
        {              
            #if USING_ASM_GETNUM == 0         
                if(getNum(list[i]) > getNum(list[i + 1]))
            #else
                if(getNum_asm(list[i]) > getNum_asm(list[i + 1]))
            #endif                
            {
                tmp = (int)list[i];
                list[i] = list[i + 1];
                list[i + 1] = (int)tmp;
                getauscht = '1';
            }
        }
    }
}

int getNum(char *string)
{   
    printf("%s - ", string);

    if(*string == 0x0)
    {
        return -1;
    }

    char *pTmp[sizeof(string)] = {};
    char *p = pTmp;
    
    do
    {       
        if(*string >= '0' && *string <= '9')
        {
            *p++ = *string;
        }
    }
    while(*string++ != '\0');
    
    printf("%d\n", atoi(pTmp));

    return atoi(pTmp);
}